﻿define([
    'require',
    'angular',
    'underscore'
], function (require, angular, _) {
    return  function ($scope,Resource,GillionMsg,$dataSourceManager,$location,$http,$timeout) {
        $http({
            method: 'GET',
            url: "/grule-manager/projects/arr"
        }).success(function (resp) {
            $scope.projectsName=resp;
        })
        if($location.search().date!=undefined) {
            $scope.startTime = new Date($location.search().date);
            $scope.startTime.setHours(0);
            $scope.endTime = new Date($location.search().date);
            $scope.endTime.setHours(24);
        }
        if($location.search().packageName!=undefined){
            $scope.packageName=$location.search().packageName;
        }
       if($location.search().name){
           $timeout(function(){
               $scope.reportParams = {
                   packageName:$location.search().name,
                   startTime:$scope.startTime,
                   endTime:$scope.endTime,
                   projectsName:$scope.projectsName
               };
               $dataSourceManager.dataSources["LoggerSource"].doRequestData(1,$scope.reportParams);
           }, 100);

       }else {
            $http({
                method: 'GET',
                url: "/grule-manager/projects/arr"
            }).success(function (resp) {
                $scope.reportParams = {
                    projectsName:resp
                };
                $dataSourceManager.dataSources["LoggerSource"].doRequestData(1,$scope.reportParams);
            });
       }

        $scope.searchLogger = function () {
            $scope.reportParams.projectsName=$scope.projectsName;
            $dataSourceManager.dataSources["LoggerSource"].doRequestData(1,$scope.reportParams);
        }
    }
});